const mysql = require("mysql")
    const { MYSQL_CONF } = require("../conf/db.js")



const con = mysql.createConnection(MYSQL_CONF)

con.connect()


function exec(sql){

    const promise = new Promise((resolve,reject) =>{

con.query(sql,(err,result) =>{

  if(err){
      console.log(err);
      reject(err)
      return
  }
  resolve(result)

}) 
  
    })
return promise
}


/* const sql = `update users set realname= '李四' where username = 'zhangsan';`

  */

module.exports = {
    exec,
    escape: mysql.escape
}